/*
	This file is part of pqrst commander.

    pqrst commander is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    pqrst commander is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with pqrst commander.  If not, see <http://www.gnu.org/licenses/>.
*/

Why I did this project.
-----------------------

Up to this point in my career, I have been an embedded systems engineer.  I had started
my career as a hardware design engineer for small battery operated, hand-held voice
recorders and MP3 players.  I then made the move to programming micro-controllers with
the Micro-chip PIC controller and finally the TI MSP430.  So, now I have moved on to
larger systems at a larger company as a test engineer and have been learning how to
work with Linux Operating Systems.  I never programmed any micro-controllers with an
operating system present. I wanted to learn more about programming with operating systems
and new that there were many free operating systems available for the MSP430 which I
was very familiar, so I decided that I would try to mimic Linux on the MSP430. 

Doing this project, I was able to learn better programming skills.  Not having been a real
software programmer from the start, I learned how to better use standard C libraries instead
of "re-inventing the wheel" and writing my own routines to accomplish the same result.

I also wanted to allow for changes in code functionality without requiring JTAG.  For small
tasks that a micro-controller sometimes are used for, I thought I would come up with a
way for these small tasks to be accomplished with the resident code and no C code required.
It would be more like a simple script to accomplish the task.

As a result, I would hope that this project would help others trying to get started using
the MSP430 as the code would show how to exercise many parts of the device as well as
running the code with an operating system.  Also, it would be a foundation for builing
upon so that more functionality could be added by myself or another developer.

I looked into many different RTOSs that were available for now cost.  I looked at TinyOS,
FreeRTOS, and Salvo RTOS.  I also looked into using GCC MSP430, IAR, and QuadraVOX tools.
GCC was difficult to use for me and IAR tools I wanted to get working since that comes
free with MSP430 Kickstart package which I have.  I chose MSP430F149 since it was a 
processor I was familiar with and the one of the parts I have that has a UART peripheral
on chip.`

The issues I had with IAR tools was that 
there was a 4K C code limit with the free version that comes with KickStart from TI.
So, I decided on QuadraVOX, since I own a legal copy of the tools and I am very failiar
with using the tools.  The RTOS I chose was Salvo since it has a release for QuadraVOX.
FreeRTOS had a release for QuadraVOX, but I believe it was not their own.  (This may not be
100% correct since I am writing this several months after I stated this project.)  Salvo
had very good documentation and it was vey easy for me to get started with their basics
for understanding RTOSs and kernels and Application Notes (AN) for getting setup for use
with QuadraVOX.  This project uses Salvo Lite, which is a free version frm Pumpkin.
It limits te number of tasks to 3, so if more is needed, an upgrade will be required and
an expense will be incurred.  I set up this project to use two tasks.  The first task is
set to handle all of the serial commands and output to the terminal.  The second task 
was setup for any application that would run from memory so that multi-tasking would be
possible for application and serial port.  The third task has been reserved for future use.
It is intended to bu used for running a second application.

This project should be easily modified should the OS part of pqrst commander is not desired.

I called this project pqrst commander.  Commander because you can enter commands via the
serial port to control the processor.  The pqrst is for the various parts that make this
project work together: 

p=pumkin, the operating system I chose for ther project www.pumkininc.com
q=quadravox, the IDE tools that I own for developing the C code
rs=rob silbert, that is me, the one responsible for ties this project all together
t=TI, Texas Instruments.  The manufacturer of the MSP430 micro-controller.

So what did I learn from this project?  To start off, I had trouble getting simple
printing to the PC terminal program over the UART.  I had to set functions
UARTInitTX() and FlashPortSettings in commander.h in a do/while loop in #define 
statement to get it working.  I mimmiced what was shown in the Salvo documentation.
Also,remember to initiallize variables when using static variables required by Salvo.

I found application note AN-18 titled Building a Salvo Application Using Quadravox's
MSP430 Development Tools.  This app notes describes how to properly setup Quadravox
to properly use Salvo libraries and the directories to Salvo files.
This program is running on top of Salvo however, this release does not take advantage
of the Salvo task switching.  That I hope to have implemented in later versions.

Since I started working on this project, I discovered an interesting project on the
web via www.makezine.com at the site www.nootropicdesign.com.  The project called
Toolduino uses a USB connection to an Arduino developement board and with a graphical
interface, allows you to control the port pins with simple mouse clicks as well as
reading port pins.  This type of GUI could also be written to handle comands across
the RS-232 port of the MSP430F149.

Commands that are currently supported in pqrst commander:

cl clears the screen");
ps ps=prompt changes command prompt text
lo logout
-v  prints version of commander;
sp#.#=# sets port and bits, sp1.1=1,sp1.1=0
   set whole port, sp1=xff, sp1=255
pr# reads port value pr1, pr6
     prp displays all port values until <ENTER>
pd#.#=# sets port direction, pd1.1=1,pd1.1=0
   set whole port direction, pd1=xff, pd1=255
   output=1, input=0
pm#.#=# set muxed port pins via P#SEL registers
   works as pd command above
su# sets new user. su1 replaces root, su2 for limited permissions
rb reboot pqrst commander
mr memory read, can read any location of ROM
    mr=x1000 will return value in hex at address x1000
    address must be 4 digits long.
lc load config. load config file using config.txt template.
pl print line. prints textup to 29 chars. ex. pl press <enter> 	
?  Prints the abovelist of available commands

I have not yet taken advantage of or actually used the benefits of the Pumpkin OS.  I hope to
release future version that will handle the task switching and learn about using the OS.
Now that I have the basics down for the user interface, I can now focus on the OS programming.

Regards,

Rob Silbert
rsilbert@yahoo.com